import request from '@/utils/request';

/**
 * 获取支付笔数数据
 */
export async function getPayNumList() {
  const res = await request.get('https://cdn.eleadmin.com/20200610/analysis-pay-num.json');
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }

  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取销售量数据
 */
export async function getSaleroomList() {
  const res = await request.get('https://cdn.eleadmin.com/20200610/analysis-saleroom.json');
  // console.log(res.data);
  if (res.code === 0 && res.data) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取最近 1 小时访问情况数据
 * @returns {Promise<Object>}
 */
export async function getVisitHourList() {
  const res = await request.get('https://cdn.eleadmin.com/20200610/analysis-visits.json');
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取词云数据
 */
export async function getWordCloudList() {
  const res = await request.get('https://cdn.eleadmin.com/20200610/analysis-hot-search.json');
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * @description: 获取柱状图图表
 * @date 2023-06-14 19:37
 */
export async function getChart() {
  return request({
    url: '/commonindex/chart',
    method: 'post',
  });
}
/**
 * @description: 获取饼状图数据
 * @date 2023-06-15 10:28
 */
export async function getRound() {
  return request({
    url: '/commonindex/histogram',
    method: 'post',
  });
}
/**
 * @description: 总数居
 * @date 2023-06-15 12:02
 */
export async function getTotal() {
  return request({
    url: '/commonindex/total',
    method: 'post',
  });
}
export function getMerTotalList(query) {
  return request({
    url: '/deal/deal/agent/getMerTotalList',
    method: 'get',
    params: query,
  });
}
